#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int Is_Leap_Year(int year)
{
    if ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0))
    {
        return 1;
    }
    else
        return 0;
}

int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int DAY = 0;
    int Month[2][13] = { {0,31,29,31,30,31,30,31,31,30,31,30,31},
                         {0,31,28,31,30,31,30,31,31,30,31,30,31} };
    scanf("%d %d %d", &year, &month, &day);
    int ret = Is_Leap_Year(year);
    for (int i = 0; i < month; i++)
    {
        DAY += Month[ret][i];
    }
    printf("%d", DAY + day);
    return 0;
}